// 胜率仪表盘
// 左边扇形
function drawChartS(id,data){
    return new Highcharts.Chart({
        chart: {
            type: 'solidgauge',
            renderTo: id,
            plotBackgroundColor: null,
            plotBorderWidth: 0,
            plotShadow: false,
            backgroundColor: '#171922',
        },
        credits: {
            enabled: false
        },
        // 去掉右上角打印提示
        exporting:{
            enabled: false
        },
        title: null,
        pane: {
            center: ['50%', '85%'],
            size: '160%',
            startAngle: -90,
            endAngle: 90,
            background: {
                backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
                innerRadius: '60%',
                outerRadius: '100%',
                shape: 'arc'
            }
        },
        tooltip: {
            enabled: false
        },
        // the value axis
        yAxis: {
            stops: [
                [0.1, '#3B9CE0'], // blue
                [0.9, '#3B9CE0'] //  blue
            ],
            lineWidth: 0,
            minorTickInterval: null,
            tickPixelInterval: null, //隐藏左右最大值和最小值的提示
            tickWidth: 0,
            min: 0,
            max: 100, //环形总量
            title: {
                text: ''
            }
        },
        plotOptions: {
            solidgauge: {
                dataLabels: {
                    borderWidth: 0,
                    useHTML: false
                }
            }
        },
        series: [{
            name: '胜率',
            data: data,//胜率的数据
            dataLabels: {
                format: '<div style="text-align:center;display:none;"><span style="font-size:0.5rem;"></span><br/>'
                // <div style="text-align:center;display:none;"><span style="font-size:0.5rem;">'+data+'</span>%<br/>
            }
        }]
    })
}
//交易品种   饼形图
function drawChartB(id,datastr){
    var myChartPie = echarts.init(document.getElementById(id));
	option = {
	    title : {
	        text: '',
	        subtext: '',
	        x:'center'
	    },
	    tooltip : {
	        trigger: 'item',
	        formatter: "{a} <br/>{b} : {c} ({d}%)"
	    },
	    series : [
	        {
	            name: '',
	            type: 'pie',
	            radius : '80%',
	            center: ['50%', '50%'],
	            data: datastr
	        }
	    ],
	    color: ['#F7A35C','#8FED7D','#434248','#7CB5EC','#8185E9','#F05D7F']
	};
     myChartPie.setOption(option);
}
//交易报表  曲线图
function jiaoyiChart(id,data){
    var t = this;
    return new Highcharts.Chart({
        chart: {
            renderTo: id,
            type: "areaspline",
            zoomType: "xy",
            pinchType:'',// 让在移动端可以滑动
            backgroundColor: '#171922'
        },
        title: {
            text: null
        },
        colors: ["#ffc766"],
        legend: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        exporting: {
            enabled:false
        },
        xAxis: {
            gridLineWidth: 0,
            lineColor: "#2E303E",
            tickColor: "#2E303E",
            gridLineColor: "#2E303E",
            categories:data[0],
            tickInterval: Math.ceil(data[0].length / 7),
            labels: {
            	rotation: false,
            }
        },
        yAxis: {
            gridLineWidth: 1,
            lineColor: "#2E303E",
            tickColor: "#2E303E",
            gridLineColor: "#2E303E",
            title: {
                text: null
            },
            labels: {
            }
        },
        tooltip: {
            style: {
                color: "white"
            },
            borderWidth: 0,
            shadow: !1,
            backgroundColor: "rgba(34,34,34, 0.6)",
            shared: !0
        },
        plotOptions: {
            areaspline: {
                fillColor: {
                    linearGradient: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 1
                    },
                    stops: [
                        [0, "#3b9ce0"],
                        [1, Highcharts.Color("#3b9ce0").setOpacity(0).get('rgba')]
                    ]
                },
                marker: {
                    radius: 0,
                    fillColor: "white",
                    lineWidth: 1,
                    lineColor: "#ffc766"
                },
                lineWidth: 1,
                states: {
                    hover: {
                        lineWidth: 1
                    }
                },
                threshold: null
            },
            series: {
                lineColor: "#3b9ce0"
            }
        },
        series: [{
            name: "盈利点位",
            data: data[1]
        }]
    })
}
$(function(){
    var swiper = new Swiper('.swiper-container', {
        width: 0,
        height: 0,
        slidesPerView: 3,
        centeredSlides: true,
        paginationClickable: true,
        passiveListeners : false,
        spaceBetween: 0,
        grabCursor: true,
        slidesOffsetBefore : 1, //与左边框偏移量
        direction : 'horizontal',
        resistanceRatio: 0,
        centeredSlides: true,
        paginationClickable: true,
        onInit: function(swiper){ //初始化改变宽度
            var w = 13.006+'rem';
            var h = 7.484+'rem';
            $(".swiper-slide").css({'width': w,'height':h});
        },
        onTouchEnd: function(swiper){
            var x = swiper.getWrapperTranslate('x');
            if(x <= -660) {
                swiper.setWrapperTranslate(-660,0,0);
            }
            if(x >= 15) {
                swiper.setWrapperTranslate(15,0,0);
            }
        }
   });

})
